<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>测试SSE流式展示</title>
</head>
<body>
<h1>测试SSE流式展示</h1>
<button onclick="send()">测试开始</button>
<br>
<div id="stock-price"></div>

<script>
    function send(){
        const message = "用Java写一个简单程序";
        console.log("开始")
        const webSocket = new WebSocket("ws://localhost:8101/call",null,{
            headers:{
                "token":"eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3MjI4MzY0OTYsInVzZXJJZCI6MSwiaWF0IjoxNzIyODI1Njk2LCJqdGkiOiIxIn0.L9TQmh8-_W8CUI6EcpPWAVWI9LCbzE3pTBzBBCuB_wQ"
            }
        });
        webSocket.onopen = function (event) {
            console.log("连接成功")
        }
        webSocket.onmessage = function (event) {
            console.log("收到消息")
            document.getElementById("stock-price").innerHTML = event.data;
        }
        webSocket.onclose = function (event) {
            console.log("连接关闭")
        }

    }

</script>
</body>
</html>
